package com.cheer.dto;

import cn.hutool.core.date.DateUtil;
import com.cheer.enums.ReviewTypeEnum;
import com.cheer.enums.TitleEnum;
import com.cheer.vo.StandingBookReviewVO;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@Accessors(chain = true)
public class StandingBookReviewPageDTO {

    private Long reviewId;

    private String applicantName;

    private String orgName;

    private String contactPerson;

    private String phone;

    private Date submitTime;

    private Integer registerTitle;

    private Integer title;

    private Integer reviewType;

    private Integer reviewStatus;

    public StandingBookReviewVO build() {
        StandingBookReviewVO standingBookReviewVO = new StandingBookReviewVO();
        standingBookReviewVO.setReviewId(reviewId);
        standingBookReviewVO.setApplicantName(applicantName);
        standingBookReviewVO.setOrgName(orgName);
        standingBookReviewVO.setContactPerson(contactPerson);
        standingBookReviewVO.setPhone(phone);
        standingBookReviewVO.setSubmitTime(DateUtil.formatDateTime(submitTime));
        if (title == TitleEnum.NO.getType()) {
            standingBookReviewVO.setTitle(registerTitle);
            standingBookReviewVO.setAwarded(false);
        } else {
            standingBookReviewVO.setTitle(title);
            standingBookReviewVO.setAwarded(true);
        }
        standingBookReviewVO.setJoin(reviewType == ReviewTypeEnum.JOIN.getCode());
        standingBookReviewVO.setStatus(reviewStatus);
        return standingBookReviewVO;
    }
}
